#set($serviceClass=${strUtil.au($objectName)}+'Service')
#set($serviceVar=${strUtil.al($objectName)}+'Service')
#set($objectName=${strUtil.au($objectName)})
#set($objectVar=${strUtil.al($objectName)})
#set($paramClass=${strUtil.au($objectName)}+'Param')
#set($daoClass=${strUtil.au($objectName)}+'Dao')
#set($daoVar=${strUtil.al($objectName)}+'Dao')

package ${basePackageName}.${moduleName}.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.newproj.core.beans.MapParam;
import com.newproj.core.exception.BusinessException;
import com.newproj.core.rest.support.AbstractBaseService;
import com.newproj.core.util.NumberUtil;
import com.newproj.core.util.TimeUtil;

import ${basePackageName}.${moduleName}.dal.dao.BannerDao;
import ${basePackageName}.${moduleName}.dto.Banner;
import ${basePackageName}.${moduleName}.dto.BannerParam;



@Service
public class ${serviceClass} extends AbstractBaseService{

	@Autowired
	private ${daoClass} ${daoVar} ;
	
	@Override
	public void setMapper(){
		this.mapper = ${daoVar} ;
	}

	
	public int create${objectName}( ${paramClass} param ){
		param.setCreateTime( TimeUtil.timestamp() );
		return NumberUtil.parse( ${daoVar}.createBean( param , ${paramClass}.class ), 0 ) ;
	}
	
	public void update${objectName}( int id , ${paramClass} param ){
		if( ${daoVar}.findMapBy("id", id, "id") == null )
			throw new BusinessException("数据不存在!") ;
		param.setUpdateTime( TimeUtil.timestamp() );
		${daoVar}.updateBean("id", id, param ) ;
	}
	
	public int delete${objectName}( int id , int userId ){
		if( ${daoVar}.findMapBy("id", id, "id") == null )
			return 0 ;
		return ${daoVar}.updateMap("id", id , new MapParam<String,Object>()
				.push("isDeleted" , 1 )
				.push("updateTime" , TimeUtil.timestamp() )
				.push("updateId" , userId ) ) ;
	}
	
	public void setStatus( int id , int userId ){
		${objectName} ${objectVar} ;
		if( ( ${objectVar} = ${daoVar}.findBeanBy("id", id, ${objectName}.class ) ) == null )
			throw new BusinessException("数据不存在!") ;
		${daoVar}.updateMap("id" , id , new MapParam<String,Object>()
				.push("status" , ${objectVar}.getStatus() > 0 ? 0 : 1 )
				.push("updateTime" , TimeUtil.timestamp() )
				.push("updateId" , userId ) ) ;
	}
	
}
